#include "WatchEventHandlerI.h"
#include "DataAccess.h"

using namespace std;
using namespace iPlature;
using namespace Monitor;
void CWatchEventHandlerI::EventWatchWithData(const iPlature::TAGVALUEMAP &tagValueMap,
                                             const std::string &strEventName, const std::string &strValue,
                                             const Ice::Current &)
{
  // 加锁保护参数值
  IceUtil::Mutex::Lock lock(m_mutexValue);
  const bool isEvWeb = strEventName.substr(0, 7) == "EV_WEB_";
  if (!isEvWeb) {
    return;
  }
  const string insertSql = "insert into UACS_WEB_TAG_WS (TAGNAME, TAGVALUE) values ('" + strEventName + "','" + strValue + "')";
  CDataAccess::GetInstance()->Initialize();
  iDA::Command cmd(&CDataAccess::GetInstance()->m_DBCon, insertSql);
  cmd.Execute();
}
